
import {caseMethod} from '@/utils/models/case.js'
const crudMethod = new caseMethod();
import {homeMethod} from '@/utils/models/index.js'
const indexMethod = new homeMethod();
import Footer from '@/components/footer-main'
export default {
  name: 'Home',
  components: { Footer},
  data() {
    return {
      caseLoad: false,
      caseType: '',
      caseData: [],
      bannerData: [],
      dictionaryData: [],
      curId: 'all',
      typeData: [
        { key: 0, value: 'all', label: '经典案例'},
        { key: 1, value: 'app', label: 'APP'},
        // { key: 2, value: 'big', label: '大数据'},
        // { key: 3, value: 'apply', label: '应用软件'},
        { key: 4, value: 'website', label: '网站建设'},
        { key: 5, value: 'small', label: '小程序'},
        { key: 6, value: 'public', label: '微信公众号'}
      ],

      tabIcon: [
        require('@/assets/images/project_app_01.png'),
        require('@/assets/images/project_app_02.png'),
        require('@/assets/images/project_app_03.png'),
        require('@/assets/images/project_app_04.png'),
        require('@/assets/images/project_app_05.png'),
        require('@/assets/images/project_app_06.png'),
        require('@/assets/images/project_app_07.png')
      ],
      tabIcona: [
        require('@/assets/images/project_app_01a.png'),
        require('@/assets/images/project_app_02a.png'),
        require('@/assets/images/project_app_03a.png'),
        require('@/assets/images/project_app_04a.png'),
        require('@/assets/images/project_app_05a.png'),
        require('@/assets/images/project_app_06a.png'),
        require('@/assets/images/project_app_07a.png')
      ],
    }
  },
  created() {
    document.title = '朔悦案例'
    this.getCmfBanner()
    this.getDictionarys()
    this.getQuery()
  },
  methods: {
    getDictionarys() {
      let _this = this
      indexMethod.getDictionary('典型案例').then((res) => {
        let {msg, code, data} = res;
        _this.dictionaryData = data.data
      })
    },
    handleChange(tab) {
      this.curId = tab
      let list = Array.apply(null, this.caseData).map(item => item)
      this.caseData = list
    },
    // 轮播图
    getCmfBanner () {
      let _this = this
      _this.bannerData = []
      indexMethod.frontCmfBanner(2).then((res) => {
        let {msg, code, data} = res;
        data.data.forEach(item => {
          item.bannerImg = item.bannerImg ? _this.baseURL + item.bannerImg : ''
        })
        _this.bannerData = data.data
      })
    },
    // 分页查询案例
    getQuery () {
      let _this = this
      _this.caseLoad = true
      crudMethod.getCase(_this.caseType).then((res) => {
        _this.caseLoad = false
        let {msg, code, data} = res;
        data.data.forEach(item => {
          item.caseMinImg = item.caseMinImg ? item.caseMinImg.split(',') : []
        })
        _this.caseData = data.data
      })
    },
  }
}
